/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 *
 * @author william
 */
public class Ficha extends javax.swing.JPanel implements MouseListener {

    private ArregloFichas tablero;
    private ImageIcon fondo;
    private static int[] casillaMarcada = new int[2];

    public Ficha() {
        // este constructor no se usar&aacute;, se deja para poder crear el bean.        
    }

    public Ficha(ArregloFichas t) {
        initComponents();
        this.tablero = t;
        this.addMouseListener(this);
    }

    public void setFondo(ImageIcon fondo) {
        this.fondo = fondo;
    }

    public ImageIcon getFondo() {
        return this.fondo;
    }

    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 161, Short.MAX_VALUE));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 193, Short.MAX_VALUE));
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(fondo.getImage(), 0, 0, this.getWidth(), this.getHeight(), this);
    }

    @Override
    public void mouseClicked(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

    @Override
    public void mousePressed(MouseEvent e) {

        Ficha.setCasillaMarcada(tablero.getCoordenadas((Ficha) e.getComponent()));

    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    public static int[] getCasillaMarcada() {
        return casillaMarcada;
    }

    public static void setCasillaMarcada(int[] aCasillaMarcada) {
        casillaMarcada = aCasillaMarcada;
    }
}
